/**
 * @param {string} digits
 * @return {string[]}
 */

var letterCombinations = function (digits) {
    let map = new Map([
        ["2", "abc"],
        ["3", "def"],
        ["4", "ghi"],
        ["5", "jkl"],
        ["6", "mno"],
        ["7", "pqrs"],
        ["8", "tuv"],
        ["9", "wxyz"],
    ])
    // 如果不存在
    if (!digits || !digits.length) {
        return []
    }
    // 答案数组
    let res = []
    // 运营数组
    let arr = []
    backtracking(0)
    return res
    function backtracking(index) {
        // 取得相应digits[index]映射
        let s = map.get(digits[index])
        // 边界条件
        if (arr.length === digits.length) {
            res.push(arr.join(""))
            return 
        }
        for (let i = 0; i < s.length; i++) {
            arr.push(s[i])
            backtracking(index + 1)
            arr.pop()
        }
    }
};
console.log(letterCombinations("23"))